<!--chapter7\zhihuiyuan\templates\newuser.html-->
<!DOCTYPE html>
<html lang="en">
<head>
  <script src="/static/jquery-3.4.1.min.js"></script>
  <link rel="stylesheet" type="text/css" href="/static/newuser.css"/>
    <meta charset="UTF-8">
    <title>智慧园</title>
</head>
<body>
<center>
  <br><br>
    <a id="p1">智慧园新用户注册</a>
  <br><br>
  <hr>
  <br><br><br><br>
    <table align="center">
      <tr>

        <td><input type="text" id="uid" maxlength="10" placeholder="请输入用户ID" >
         <span id="ruid"></span>
        </td>
      </tr>
      <tr>

        <td><input type="password" id="pwd1" maxlength="8" placeholder="请输入密码" ></td>
      </tr>
      <tr>

        <td><input  type="password" id="pwd2" maxlength="8" placeholder="再次输入密码" ></td>
      </tr>
      <tr>

        <td>
          <input  type="password" id="email" maxlength="20" placeholder="请输入Email" >
        </td>
      </tr>
      <tr>

        <td>
          <img src="/gerpng/" id="icode">单击刷新<br/>
          <input type="text"  align="center" id="code" maxlength="10" placeholder="请输入验证码">
        </td>
      </tr>
      <tr>
        <td colspan="2" >
          <input type="button" value="提交" id="submit" maxlength="20">
        </td>
      </tr>
    </table>
  <script>
    var codeok =false
    var idok =false
    $(document).ready(function() {
        $('input').html('')  });
    $('#uid').keyup(function (){
        var uid = $("#uid").val();
    $.get("/checkuid/",{'uid':uid},function(r) {
         if (r == 'ID可用') { idok =true} else {idok = false }
         $('#ruid').html(r)  })
    });
    $('#icode').click(function () {
         var a = (new Date()).toTimeString()
         $('#icode').attr('src','   getpng/?t=' +a)
         codek = false });
        $.get("/checkcode/", {} , function (r) {
            if (r.toLowerCase() == code.toLowerCase()) { codeok = true }
        else { codeok = false }
        });
    $('#submit').click(function () {
        if (!idok) {
           $('#result').html('<span style="color:red">你输入的ID用户已被占用！ </span>')
           return 1}
        var pwd1 = $("#pwd1").val();
        var pwd2 = $("#pwd2").val();
        pwdok = false
        if (pwd1 !=pwd2) {
           $('#result').html('<span style="color:red">两次输入的密码不一致！ </span>')
           return 1}
        var reg = /^\w+@[a-zA-Z0-9]{2,10}(?:\.[a-z]{2,4}){1,3}$/;
        if (!reg.test($("#email").val())) {
           $('#result').html('<span style="color:red">你输入的Email地址无效！ </span>')
           return 1}
        if(!codeok) {
            $('#result').html('<span style="color:red">验证码输入错入！ </span>')
           return 1}
        var uid = $("#uid").val();
        var uid = $("#uid1").val();
        var email = $("#email").val();
        var date = { 'uid' :uid, 'pwd': pwd, 'email': email }
        $.get("/addnew/", {'uid' :uid, 'pwd': pwd, 'email': email },
               function (r) { $('#result').html(r) }) });
    });
  </script>
</center>
</body>
</html>